export enum AuthMethod {
    SSO = 'sso',
    DD = 'dingTalk',
    CUSTOM = 'custom',
}
export enum RouterMode {
    HASH = 'hash',
    HISTORY = 'history'
}
export enum CacheType {
    COOKIE = 'cookie',
    SESSION = 'session'
}
export interface AuthClientOption {
    SSOServer: string;
    resourceCode: string;
    routerMode: RouterMode;
    jwtToken?: boolean;
    method?: AuthMethod;
    cacheMode?: CacheType;
}
export interface CustomLoginOption {
    username: string;
    password: string;
    phone?: string;
    loginCode?: string; // 图片验证码
    loginCodeId?: string; // 图片验证码id
    isQrCode:number
}

export interface PhoneLoginOption {
    smsMob: string;
    smsCode: string;
}
export interface QrCodeOption {
    eleId: string; // 原生dom的id属性
    redirectUrl?: string; // 自定义回调地址
}
export interface ImageCodeSucResult {
    loginCodeId: string;
    img: string;
}
export interface ResponseBody {
    code: number | string;
    data: any;
    msg: string,
}
export interface TokenInfo {
    access_token: string;
    token_type: string;
    refresh_token: string;
    expires_in: number
}
export const createDefaultOption = (opt = {}): AuthClientOption => {
    const defaultOption: AuthClientOption = {
        SSOServer: 'https://auth-test.jxwrd.gov.cn/',
        resourceCode: 'code',
        jwtToken: true,
        routerMode: RouterMode.HASH,
        method: AuthMethod.SSO,
        cacheMode: CacheType.SESSION,
    }
    return Object.assign(defaultOption, opt)
}

export const ACEvents = {
    INITED: 'inited',
    ERROR: 'error',
};
